cmake_minimum_required(VERSION 3.5)
project(ipa_building_navigation)

# build with c++11
if(NOT CMAKE_CXX_STANDARD)
  set(CMAKE_CXX_STANDARD 14)
endif()

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
  add_compile_options(-Wall -Wextra -Wpedantic)
endif()

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-pedantic")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-sign-compare")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-variable")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-but-set-variable")

find_package(ament_cmake REQUIRED)
find_package(rclcpp_action REQUIRED)
find_package(nav_msgs REQUIRED)
find_package(nav2_msgs REQUIRED)
find_package(geometry_msgs REQUIRED)
find_package(sensor_msgs REQUIRED)
find_package(visualization_msgs REQUIRED)
find_package(nav2_util REQUIRED)
find_package(cv_bridge REQUIRED)
find_package(ipa_building_msgs REQUIRED)
find_package(rclcpp REQUIRED)
find_package(tf2_ros REQUIRED)
find_package(tf2 REQUIRED)

find_package(OpenCV REQUIRED)
find_package(Boost REQUIRED COMPONENTS system thread chrono)

set(dependencies
    nav2_util
	cv_bridge
	geometry_msgs
	ipa_building_msgs
	rclcpp
	sensor_msgs
	visualization_msgs
    rclcpp_action
	nav_msgs
	nav2_msgs
	tf2_ros
	tf2
)
###################################
## catkin specific configuration ##
###################################
## The catkin_package macro generates cmake config files for your package
## Declare things to be passed to dependent projects
## INCLUDE_DIRS: uncomment this if you package contains header files
## LIBRARIES: libraries you create in this project that dependent projects also need
## CATKIN_DEPENDS: catkin_packages dependent projects also need
## DEPENDS: system dependencies of this project that dependent projects also need
# important: common/include needs to be here if you have such a directory


###########
## Build ##
###########
## Specify additional locations of header files
## Your package locations should be listed before other locations
# include_directories(include ${catkin_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS})
# important: common/include also needs to be here if you have it
include_directories(
    include
	common/include
	ros/include
	${OpenCV_INCLUDE_DIRS}
	${Boost_INCLUDE_DIRS}
)

# TSP library
add_library(tsp_solvers SHARED
	common/src/A_star_pathplanner.cpp
	common/src/node.cpp
	common/src/nearest_neighbor_TSP.cpp
	common/src/genetic_TSP.cpp
	common/src/concorde_TSP.cpp
)
target_link_libraries(tsp_solvers
	${OpenCV_LIBRARIES}
	${Boost_LIBRARIES}
)
ament_target_dependencies(tsp_solvers
  ${dependencies}
)
# package library
add_library(${PROJECT_NAME} SHARED
	common/src/maximal_clique_finder.cpp
	common/src/set_cover_solver.cpp
	common/src/trolley_position_finder.cpp
)
target_link_libraries(${PROJECT_NAME}
	${OpenCV_LIBRARIES}
	${Boost_LIBRARIES}
)
ament_target_dependencies(${PROJECT_NAME}
  ${dependencies}
)
# # action provider
add_executable(room_sequence_planning_server
	ros/src/room_sequence_planning_action_server.cpp
	)
target_link_libraries(room_sequence_planning_server
	tsp_solvers
	${PROJECT_NAME}
	${OpenCV_LIBRARIES}
	${Boost_LIBRARIES}
)
ament_target_dependencies(room_sequence_planning_server  ${dependencies} )


# client for testing purpose
add_executable(room_sequence_planning_client
	ros/src/room_sequence_planning_action_client.cpp
	)
target_link_libraries(room_sequence_planning_client
	${OpenCV_LIBRARIES}
)
ament_target_dependencies(room_sequence_planning_client  ${dependencies} )

# # client for testing purpose
#add_executable(room_sequence_planning_evaluation 
#	ros/src/room_sequence_planning_evaluation.cpp
#	common/src/A_star_pathplanner.cpp
#	common/src/node.cpp
#)
#target_link_libraries(room_sequence_planning_evaluation
#	${OpenCV_LIBRARIES}
#)
#ament_target_dependencies(room_sequence_planning_evaluation  ${dependencies} )


# client for testing purpose
#add_executable(ipa_room_planning_node 
#	ros/src/ipa_room_planning_node.cpp
#	ros/src/ipa_room_planning.cpp
#	)
#target_link_libraries(ipa_room_planning_node
#	${OpenCV_LIBRARIES}
#)
#ament_target_dependencies(ipa_room_planning_node  ${dependencies} )


# # evaluation
# add_executable(TSP_evaluation
# 	ros/src/boosttest.cpp
# )
# target_link_libraries(TSP_evaluation
# 	tsp_solvers
# 	${OpenCV_LIBRARIES}
# )
# ament_target_dependencies(TSP_evaluation  ${dependencies} )

#tester for different functions
#add_executable(a_star_tester ros/src/tester.cpp common/src/A_star_pathplanner.cpp common/src/node.cpp common/src/nearest_neighbor_TSP.cpp common/src/genetic_TSP.cpp common/src/concorde_TSP.cpp common/src/maximal_clique_finder.cpp common/src/set_cover_solver.cpp common/src/trolley_position_finder.cpp)
#target_link_libraries(a_star_tester ${catkin_LIBRARIES} ${OpenCV_LIBRARIES} ${Boost_LIBRARIES})
#add_dependencies(a_star_tester ${catkin_EXPORTED_TARGETS} ${${PROJECT_NAME}_EXPORTED_TARGETS})


#############
## Install ##
#############
# Mark executables and/or libraries for installation
install(TARGETS ${PROJECT_NAME} tsp_solvers 
						room_sequence_planning_server 
						room_sequence_planning_client
						#room_sequence_planning_evaluation
						#ipa_room_planning_node
						#TSP_evaluation#a_star_tester tester
    ARCHIVE DESTINATION lib
    LIBRARY DESTINATION lib
    RUNTIME DESTINATION lib/${PROJECT_NAME}
)

#uncomment this if you have a common-directory with header-files
install(DIRECTORY common/include/${PROJECT_NAME}/
	DESTINATION include/${PROJECT_NAME}/
)

#uncomment this if you have header-files in your project
install(DIRECTORY ros/include/${PROJECT_NAME}/
	DESTINATION include/
)

#install(DIRECTORY scripts
#	DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
#	PATTERN ".svn" EXCLUDE
#)

##uncomment this if you use launch and yaml files
install(DIRECTORY ros/launch
	DESTINATION share/${PROJECT_NAME}
)
ament_package()

#install(DIRECTORY common/files
#	DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/common
#	PATTERN ".svn" EXCLUDE
#)
